package main

import "fmt"

type UncleA struct {
	Name string
	Age  int
}

type UncleB struct {
	Name  string
	Score float64
}

// Nephew C 多个继承叫多重继承，不推荐使用
type Nephew struct {
	UncleB //继承
	UncleA //继承
	Name   string
}

type Niece struct {
	a UncleA //组合关系~
}

// 多重继承和组合的区别：
func main() {
	var n *Nephew = new(Nephew)
	(*n).Name = "Nephew-tom"
	(*n).UncleA.Name = "UncleA-jack"
	(*n).UncleA.Age = 55
	(*n).UncleB.Name = "UncleB-tomas"
	(*n).UncleB.Score = 100.0
	fmt.Println(*n) //{{UncleB-tomas 100} {UncleA-jack 55} Nephew-tom}

	//有名称的结构体 必须使用d.a.来访问
	var ni *Niece = new(Niece)
	ni.a.Name = "UncleA-tom"
	ni.a.Age = 53
	fmt.Println(ni.a) //{UncleA-tom 53}

}
